home *** CD-ROM | disk | FTP | other *** search
/ Skunkware 5 / Skunkware 5.iso / man / cat.3 / CrtMainWin.3 < prev    next >
Encoding:
Text File  |  1995-07-26  |  19.7 KB  |  331 lines

  1.  
  2.  
  3.  
  4.      TTTTkkkk____CCCCrrrreeeeaaaatttteeeeMMMMaaaaiiiinnnnWWWWiiiinnnnddddoooowwww((((3333))))       TTTTkkkk (((( ))))        TTTTkkkk____CCCCrrrreeeeaaaatttteeeeMMMMaaaaiiiinnnnWWWWiiiinnnnddddoooowwww((((3333))))
  5.  
  6.  
  7.  
  8.      _________________________________________________________________
  9.  
  10.      NNNNAAAAMMMMEEEE
  11.           Tk_CreateMainWindow,                        Tk_CreateWindow,
  12.           Tk_CreateWindowFromPath,                   Tk_DestroyWindow,
  13.           Tk_MakeWindowExist - create or delete window
  14.  
  15.      SSSSYYYYNNNNOOOOPPPPSSSSIIIISSSS
  16.           ####iiiinnnncccclllluuuuddddeeee <<<<ttttkkkk....hhhh>>>>
  17.  
  18.           Tk_Window
  19.           TTTTkkkk____CCCCrrrreeeeaaaatttteeeeMMMMaaaaiiiinnnnWWWWiiiinnnnddddoooowwww(_i_n_t_e_r_p, _s_c_r_e_e_n_N_a_m_e, _b_a_s_e_N_a_m_e, _c_l_a_s_s_N_a_m_e)  |
  20.  
  21.           Tk_Window
  22.           TTTTkkkk____CCCCrrrreeeeaaaatttteeeeWWWWiiiinnnnddddoooowwww(_i_n_t_e_r_p, _p_a_r_e_n_t, _n_a_m_e, _t_o_p_L_e_v_S_c_r_e_e_n)
  23.  
  24.           Tk_Window
  25.           TTTTkkkk____CCCCrrrreeeeaaaatttteeeeWWWWiiiinnnnddddoooowwwwFFFFrrrroooommmmPPPPaaaatttthhhh(_i_n_t_e_r_p, _t_k_w_i_n, _p_a_t_h_N_a_m_e, _t_o_p_L_e_v_S_c_r_e_e_n)
  26.  
  27.           TTTTkkkk____DDDDeeeessssttttrrrrooooyyyyWWWWiiiinnnnddddoooowwww(_t_k_w_i_n)
  28.  
  29.           TTTTkkkk____MMMMaaaakkkkeeeeWWWWiiiinnnnddddoooowwwwEEEExxxxiiiisssstttt(_t_k_w_i_n)
  30.  
  31.      AAAARRRRGGGGUUUUMMMMEEEENNNNTTTTSSSS
  32.           Tcl_Interp   *_i_n_t_e_r_p         (out)     Tcl  interpreter   to
  33.                                                  use     for     error
  34.                                                  reporting.    If   no
  35.                                                  error   occurs,  then
  36.                                                  *_i_n_t_e_r_p         isn't
  37.                                                  modified.         For
  38.                                                  TTTTkkkk____CCCCrrrreeeeaaaatttteeeeMMMMaaaaiiiinnnnWWWWiiiinnnnddddoooowwww,
  39.                                                  this  interpreter  is
  40.                                                  associated
  41.                                                  permanently  with the
  42.                                                  created  window,  and
  43.                                                  Tk-related   commands
  44.                                                  are  bound  into  the
  45.                                                  interpreter.
  46.  
  47.           char         *_s_c_r_e_e_n_N_a_m_e     (in)      String name of screen
  48.                                                  on  which  to  create
  49.                                                  window.  Has the form
  50.                                                  _d_i_s_p_l_a_y_N_a_m_e...._s_c_r_e_e_n_N_u_m,
  51.                                                  where _d_i_s_p_l_a_y_N_a_m_e  is
  52.                                                  the name of a display
  53.                                                  and  _s_c_r_e_e_n_N_u_m  is  a
  54.                                                  screen   number.   If
  55.                                                  the dot and _s_c_r_e_e_n_N_u_m
  56.                                                  are    omitted,   the
  57.                                                  screen         number
  58.                                                  defaults  to  0.   If
  59.                                                  _s_c_r_e_e_n_N_a_m_e is NULL or
  60.  
  61.  
  62.  
  63.      Page 1                                          (printed 7/23/95)
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.      TTTTkkkk____CCCCrrrreeeeaaaatttteeeeMMMMaaaaiiiinnnnWWWWiiiinnnnddddoooowwww((((3333))))       TTTTkkkk (((( ))))        TTTTkkkk____CCCCrrrreeeeaaaatttteeeeMMMMaaaaiiiinnnnWWWWiiiinnnnddddoooowwww((((3333))))
  71.  
  72.  
  73.  
  74.                                                  empty         string,
  75.                                                  defaults to  contents
  76.                                                  of            DISPLAY
  77.                                                  environment variable.
  78.  
  79.           char         *_b_a_s_e_N_a_m_e       (in)      Name to use for  this
  80.                                                  main   window.    See
  81.                                                  below for details.
  82.  
  83.           char         *_c_l_a_s_s_N_a_m_e      (in)      Class  to   use   for  |
  84.                                                  application  and  for  |
  85.                                                  main window.
  86.  
  87.           Tk_Window    _p_a_r_e_n_t          (in)      Token for the  window
  88.                                                  that  is  to serve as
  89.                                                  the logical parent of
  90.                                                  the new window.
  91.  
  92.           char         *_n_a_m_e           (in)      Name to use for  this
  93.                                                  window.     Must   be
  94.                                                  unique   among    all
  95.                                                  children  of the same
  96.                                                  _p_a_r_e_n_t.
  97.  
  98.           char         *_t_o_p_L_e_v_S_c_r_e_e_n   (in)      Has  same  format  as
  99.                                                  _s_c_r_e_e_n_N_a_m_e.  If NULL,
  100.                                                  then  new  window  is
  101.                                                  created     as     an
  102.                                                  internal window.   If
  103.                                                  non-NULL,  new window
  104.                                                  is created as a  top-
  105.                                                  level    window    on
  106.                                                  screen  _t_o_p_L_e_v_S_c_r_e_e_n.
  107.                                                  If _t_o_p_L_e_v_S_c_r_e_e_n is an
  108.                                                  empty  string  (``'')
  109.                                                  then  new  window  is
  110.                                                  created as  top-level
  111.                                                  window   of  _p_a_r_e_n_t's
  112.                                                  screen.
  113.  
  114.           Tk_Window    _t_k_w_i_n           (in)      Token for window.
  115.  
  116.           char         *_p_a_t_h_N_a_m_e       (in)      Name of  new  window,
  117.                                                  specified   as   path
  118.                                                  name           within
  119.                                                  application     (e.g.
  120.                                                  ....aaaa....bbbb....cccc).
  121.      _________________________________________________________________
  122.  
  123.  
  124.      DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN
  125.           The three procedures  TTTTkkkk____CCCCrrrreeeeaaaatttteeeeMMMMaaaaiiiinnnnWWWWiiiinnnnddddoooowwww,  TTTTkkkk____CCCCrrrreeeeaaaatttteeeeWWWWiiiinnnnddddoooowwww,
  126.  
  127.  
  128.  
  129.      Page 2                                          (printed 7/23/95)
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136.      TTTTkkkk____CCCCrrrreeeeaaaatttteeeeMMMMaaaaiiiinnnnWWWWiiiinnnnddddoooowwww((((3333))))       TTTTkkkk (((( ))))        TTTTkkkk____CCCCrrrreeeeaaaatttteeeeMMMMaaaaiiiinnnnWWWWiiiinnnnddddoooowwww((((3333))))
  137.  
  138.  
  139.  
  140.           and  TTTTkkkk____CCCCrrrreeeeaaaatttteeeeWWWWiiiinnnnddddoooowwwwFFFFrrrroooommmmPPPPaaaatttthhhh  are used to create new windows
  141.           for use in Tk-based applications.  Each  of  the  procedures
  142.           returns a token that can be used to manipulate the window in
  143.           other calls to the Tk library.  If the  window  couldn't  be
  144.           created  successfully,  then  NULL  is  returned and _i_n_t_e_r_p-
  145.           >_r_e_s_u_l_t is modified to hold an error message.
  146.  
  147.           Tk supports three different kinds of windows:  main windows,
  148.           internal  windows,  and top-level windows.  A main window is
  149.           the outermost window corresponding to an application.   Main
  150.           windows   correspond   to   the   independent  units  of  an
  151.           application, such as a view on a file that  is  part  of  an
  152.           editor,  or  a clock, or a terminal emulator.  A main window
  153.           is created as a child of  the  root  window  of  the  screen
  154.           indicated  by the _s_c_r_e_e_n_N_a_m_e.  Each main window, and all its
  155.           descendants, are typically  associated  with  a  single  Tcl
  156.           command  interpreter.   An  internal  window  is an interior
  157.           window of a Tk application, such as a scrollbar or menu  bar
  158.           or  button.   A top-level window is one that is created as a
  159.           child of a screen's root window, rather than as an  interior
  160.           window,  but  which  is logically part of some existing main
  161.           window.  Examples of top-level windows are pop-up menus  and
  162.           dialog boxes.
  163.  
  164.           TTTTkkkk____CCCCrrrreeeeaaaatttteeeeMMMMaaaaiiiinnnnWWWWiiiinnnnddddoooowwww creates a new main window and associates  |
  165.           its  _i_n_t_e_r_p  argument  with that window and all its eventual  |
  166.           descendants.  TTTTkkkk____CCCCrrrreeeeaaaatttteeeeMMMMaaaaiiiinnnnWWWWiiiinnnnddddoooowwww also carries  out  several  |
  167.           other actions to set up the new application.  First, it adds  |
  168.           all the Tk commands to those  already  defined  for  _i_n_t_e_r_p.  |
  169.           Second,  it  turns  the  new  window into a ttttoooopppplllleeeevvvveeeellll widget,  |
  170.           which will cause the X window to be created  and  mapped  as  |
  171.           soon    as    the    application    goes    idle.     Third,  |
  172.           TTTTkkkk____CCCCrrrreeeeaaaatttteeeeMMMMaaaaiiiinnnnWWWWiiiinnnnddddoooowwww registers  _i_n_t_e_r_p  so  that  it  can  be
  173.           accessed  remotely  by  other Tk applications using the sssseeeennnndddd
  174.           command and the name _b_a_s_e_N_a_m_e.  Normally, _b_a_s_e_N_a_m_e  consists
  175.           of  the  name  of the application followed by a space and an
  176.           identifier for this  particular  main  window  (if  such  an
  177.           identifier  is  relevant).   For example, an editor named mmmmxxxx
  178.           displaying the file ffffoooooooo....cccc would  use  ``mx  foo.c''  as  the
  179.           basename.  An application that doesn't usually have multiple
  180.           instances, such as a clock program, would just use the  name
  181.           of the application, e.g. ``xclock''.  If _b_a_s_e_N_a_m_e is already
  182.           in  use  by  some   other   registered   interpreter,   then
  183.           TTTTkkkk____CCCCrrrreeeeaaaatttteeeeMMMMaaaaiiiinnnnWWWWiiiinnnnddddoooowwww   extends  _b_a_s_e_N_a_m_e  with  a  number  to
  184.           produce a unique name  like  ``mx  foo.c  #2''  or  ``xclock
  185.           #12''.   This  name  is  used both as the name of the window
  186.           (returned by TTTTkkkk____NNNNaaaammmmeeee) and as  the  registered  name  of  the
  187.           interpreter.   Fourth, TTTTkkkk____CCCCrrrreeeeaaaatttteeeeMMMMaaaaiiiinnnnWWWWiiiinnnnddddoooowwww sets _c_l_a_s_s_N_a_m_e as  |
  188.           the class of the application (among other  things,  this  is  |
  189.           used  for  lookups  in the option database), and also as the  |
  190.           class of the main widget.
  191.  
  192.  
  193.  
  194.  
  195.      Page 3                                          (printed 7/23/95)
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202.      TTTTkkkk____CCCCrrrreeeeaaaatttteeeeMMMMaaaaiiiinnnnWWWWiiiinnnnddddoooowwww((((3333))))       TTTTkkkk (((( ))))        TTTTkkkk____CCCCrrrreeeeaaaatttteeeeMMMMaaaaiiiinnnnWWWWiiiinnnnddddoooowwww((((3333))))
  203.  
  204.  
  205.  
  206.           Either internal or  top-level  windows  may  be  created  by
  207.           calling  TTTTkkkk____CCCCrrrreeeeaaaatttteeeeWWWWiiiinnnnddddoooowwww.   If  the _t_o_p_L_e_v_S_c_r_e_e_n argument is
  208.           NULL, then the new window will be an  internal  window.   If
  209.           _t_o_p_L_e_v_S_c_r_e_e_n  is  non-NULL,  then  the  new window will be a
  210.           top-level window:  _t_o_p_L_e_v_S_c_r_e_e_n  indicates  the  name  of  a
  211.           screen  and the new window will be created as a child of the
  212.           root  window  of  _t_o_p_L_e_v_S_c_r_e_e_n.   In  either  case  Tk  will
  213.           consider  the  new window to be the logical child of _p_a_r_e_n_t:
  214.           the new window's path name will reflect this  fact,  options
  215.           may  be  specified for the new window under this assumption,
  216.           and so on.  The only difference is that new X window  for  a
  217.           top-level  window  will not be a child of _p_a_r_e_n_t's X window.
  218.           For example, a pull-down menu's _p_a_r_e_n_t would be the  button-
  219.           like  window  used  to  invoke  it, which would in turn be a
  220.           child of the menu bar window.  A dialog box might  have  the
  221.           application's  main  window  as  its  parent.  This approach
  222.           means that all the windows of an  application  fall  into  a
  223.           hierarchical  arrangement  with  a single logical root:  the
  224.           application's main window.
  225.  
  226.           TTTTkkkk____CCCCrrrreeeeaaaatttteeeeWWWWiiiinnnnddddoooowwwwFFFFrrrroooommmmPPPPaaaatttthhhh   offers   an   alternate   way   of
  227.           specifying  new windows.  In TTTTkkkk____CCCCrrrreeeeaaaatttteeeeWWWWiiiinnnnddddoooowwwwFFFFrrrroooommmmPPPPaaaatttthhhh the new
  228.           window is specified with a  token  for  any  window  in  the
  229.           target  application  (_t_k_w_i_n),  plus  a path name for the new
  230.           window.  It produces the same effect as TTTTkkkk____CCCCrrrreeeeaaaatttteeeeWWWWiiiinnnnddddoooowwww  and
  231.           allows  both  top-level  and internal windows to be created,
  232.           depending  on  the  value  of  _t_o_p_L_e_v_S_c_r_e_e_n.   In  calls  to
  233.           TTTTkkkk____CCCCrrrreeeeaaaatttteeeeWWWWiiiinnnnddddoooowwwwFFFFrrrroooommmmPPPPaaaatttthhhh, as in calls to TTTTkkkk____CCCCrrrreeeeaaaatttteeeeWWWWiiiinnnnddddoooowwww, the
  234.           parent of the new window must exist at the time of the call,
  235.           but the new window must not already exist.
  236.  
  237.           In truth,  the  window-creation  procedures  don't  actually
  238.           issue  the  command  to X to create a window.  Instead, they
  239.           create a local data structure associated with the window and
  240.           defer  the  creation  of  the  X  window.   The  window will
  241.           actually be created  by  the  first  call  to  TTTTkkkk____MMMMaaaappppWWWWiiiinnnnddddoooowwww.
  242.           Deferred  window  creation  allows  various  aspects  of the
  243.           window (such as its size,  background  color,  etc.)  to  be
  244.           modified  after  its creation without incurring any overhead
  245.           in the X server.  When the window is finally mapped  all  of
  246.           the window attributes can be set while creating the window.
  247.  
  248.           The value returned by a window-creation procedure is not the
  249.           X  token  for  the  window (it can't be, since X hasn't been
  250.           asked to create the window yet).  Instead, it is a token for
  251.           Tk's  local  data  structure for the window.  Most of the Tk
  252.           library procedures take  Tk_Window  tokens,  rather  than  X
  253.           identifiers.    The   actual  X  window  identifier  can  be
  254.           retrieved  from  the  local   data   structure   using   the
  255.           TTTTkkkk____WWWWiiiinnnnddddoooowwwwIIIIdddd macro;  see the manual entry for TTTTkkkk____WWWWiiiinnnnddddoooowwwwIIIIdddd for
  256.           details.
  257.  
  258.  
  259.  
  260.  
  261.      Page 4                                          (printed 7/23/95)
  262.  
  263.  
  264.  
  265.  
  266.  
  267.  
  268.      TTTTkkkk____CCCCrrrreeeeaaaatttteeeeMMMMaaaaiiiinnnnWWWWiiiinnnnddddoooowwww((((3333))))       TTTTkkkk (((( ))))        TTTTkkkk____CCCCrrrreeeeaaaatttteeeeMMMMaaaaiiiinnnnWWWWiiiinnnnddddoooowwww((((3333))))
  269.  
  270.  
  271.  
  272.           TTTTkkkk____DDDDeeeessssttttrrrrooooyyyyWWWWiiiinnnnddddoooowwww deletes a window and all the data strutures
  273.           associated  with  it,  including  any event handlers created
  274.           with TTTTkkkk____CCCCrrrreeeeaaaatttteeeeEEEEvvvveeeennnnttttHHHHaaaannnnddddlllleeeerrrr.  In  addition,  TTTTkkkk____DDDDeeeessssttttrrrrooooyyyyWWWWiiiinnnnddddoooowwww
  275.           will   delete  any  children  of  _t_k_w_i_n  recursively  (where
  276.           children are defined in the  Tk  sense,  consisting  of  all
  277.           windows  that were created with the given window as _p_a_r_e_n_t).
  278.           If _t_k_w_i_n was created by TTTTkkkk____CCCCrrrreeeeaaaatttteeeeIIIInnnntttteeeerrrrnnnnaaaallllWWWWiiiinnnnddddoooowwww  then  event
  279.           handlers   interested   in   destroy   events   are  invoked
  280.           immediately.  If _t_k_w_i_n is a top-level or main  window,  then
  281.           the  event  handlers will be invoked later, after X has seen
  282.           the request and returned an event for it.
  283.  
  284.           If a window has been created but hasn't been mapped, so no X
  285.           window exists, it is possible to force the creation of the X
  286.           window by calling TTTTkkkk____MMMMaaaakkkkeeeeWWWWiiiinnnnddddoooowwwwEEEExxxxiiiisssstttt.  This procedure issues
  287.           the X commands to instantiate the window given by _t_k_w_i_n.
  288.  
  289.  
  290.      KKKKEEEEYYYYWWWWOOOORRRRDDDDSSSS
  291.           create,  deferred  creation,  destroy,   display,   internal
  292.           window,  main  window,  register,  screen, top-level window,
  293.           window
  294.  
  295.  
  296.  
  297.  
  298.  
  299.  
  300.  
  301.  
  302.  
  303.  
  304.  
  305.  
  306.  
  307.  
  308.  
  309.  
  310.  
  311.  
  312.  
  313.  
  314.  
  315.  
  316.  
  317.  
  318.  
  319.  
  320.  
  321.  
  322.  
  323.  
  324.  
  325.  
  326.  
  327.      Page 5                                          (printed 7/23/95)
  328.  
  329.  
  330.  
  331.